package bite;

/**
 * Creared with IntelliJ IDEA.
 * Description:【分解因数】所谓因子分解，就是把给定的正整数a，分解成若干个素数的乘积，即 a = a1 × a2 × a3 × ... × an,并且 1 < a1 ≤ a2 ≤ a3 ≤ ... ≤ an。其中a1、a2、
 * ...、an均为素数。 先给出一个整数a，请输出分解后的因子。
 * User:yxd
 * Date:2022-06-07
 * Time:18:08
 */
import java.util.*;
public class Day31_1 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (input.hasNextInt()){
            int num = input.nextInt();
            //将结果全部放在一个list里面方便后面处理
            List<String> list = fact(num);
            //然后进行拼接,join方法就是将list里面的所有数按这样的方式进行分割
            System.out.printf("%d = %s\n",num,String.join(" * ",list));
        }
    }

    private static List<String> fact(int num) {
        //将所有的因子放到里面去
        List<String> list = new ArrayList<>();
        for (int i = 2; i * i <= num && num > 1 ; i++) {
            while (num % i == 0){
                list.add(String.valueOf(i));
                num = num / i;
            }
        }
        if(num > 1){
            list.add(String.valueOf(num));
        }
        return list;
    }

    public static void main1(String[] args) {
        Scanner input = new Scanner(System.in);
        StringBuilder stringBuilder = new StringBuilder();
        while (input.hasNext()) {
            int num = input.nextInt();
            int count = 0;
            stringBuilder.append(num + " " + "=");
            int j = num;
            for (int i = 2;i <= Math.sqrt(j);i ++) {
                while (num % i == 0) {
                    stringBuilder.append(" " + i + " " + "*");
                    num = num/i;
                    count++;
                }
                if (num == 1) break;
            }
            if (num != 1) stringBuilder.append(" " + num);
            if (stringBuilder.charAt(stringBuilder.length()-1) == '*') {
                stringBuilder.deleteCharAt(stringBuilder.length()-1);
                stringBuilder.deleteCharAt(stringBuilder.length()-1);
            }
            System.out.println(stringBuilder);
            stringBuilder.setLength(0);
        }
    }



}